package cn.zch.soft.util.hutool.http;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

import javax.xml.namespace.QName;
/**
 * @author zchcpywin10
 */
public class TestWheathreService {
  public static void main(String[] args) {
    String cityName = "郑州";
    getStudentInfo(cityName);
  }
  public static void getStudentInfo(String param) {
    try {
      // http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName
      String url = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx";
      String namespace = "http://WebXml.com.cn/";
      Service service = new Service();
      Call call = (Call) service.createCall();
      // 设置命名空间和需要调用的方法名
      QName qname = new QName(namespace, "getWeatherbyCityName");
      call.setOperationName(qname);
      call.setTargetEndpointAddress(url);
      call.setSOAPActionURI(namespace + "getWeatherbyCityName");
      // 接口的参数
      call.addParameter(new QName(namespace, "theCityName"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
      //设置返回类型
      call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
      String result = (String) call.invoke(new Object[]{param});
      System.out.println("结果: \n" + result);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}
